

/* DEFINE VARIABLE voutput AS CHARACTER  NO-UNDO initial "\\192.168.12.12\shared$\output\csv\". */
/*                                                                                              */
/* define variable vdb like ad_name_control initial "".                                         */
/*                                                                                              */
/* for first ad_mstr no-lock where ad_addr = "~~reports".                                       */
/* end.                                                                                         */
/* if avail ad_mstr then do:                                                                    */
/*     assign vdb =  ad_name_control .                                                          */
/* end.                                                                                         */
/*                                                                                              */
/*                                                                                              */
/* find code_mstr NO-LOCK WHERE code_fldname = "exptab2csv" and code_value = "output" no-error. */
/* if avail code_mstr then do:                                                                  */
/*     assign voutput = code_cmmt.                                                              */
/* end.                                                                                         */
/*                                                                                              */
/* output to value(voutput + vdb + "ro_det.csv").                                               */

output to value({1} + {2} + "ro_det.csv").


FOR EACH ro_det NO-LOCK WHERE 
    (ro_start<= today or ro_start = ?) and (ro_end >= today or ro_end = ?):
        
    put {2} ","
        ro_routing  ","
        ro_op ","""
        trim(ro_desc) format "x(40)" ""","
        ro_wkctr  ","
        ro_setup format "->>>>>>>9.9<< " ","
        ro_run   format "->>>>>>>>9.9<<" ","
        ro_move  format "->>>>>9.9<< " ","
        ro_yield_pct format "->>>>9.99" ","
        ro_tool ","
        ro_vend ","
        ro_sub_cost format "->>>>>>>>>9.99" ",".
        if ro_start = ? then do:
            put ",".
        end.
        else do:
            put string(year(ro_start),"9999") + "-" + string(month(ro_start),"99") + "-" + string(day(ro_start),"99") format "x(10)" ",".
        end.
        if ro_end = ? then do:
            put ",".
        end.
        else do:
            put string(year(ro_end),"9999") + "-" + string(month(ro_end),"99") + "-" + string(day(ro_end),"99") format "x(10)" ",".
        end.
    put
        ro_tran_qty format  "->>>>>>>>9" ","
        ro_inv_value format "->>>>>>>>>>>9.99" ","
        ro_cmtindx format ">>>>>>>>>9" ","
        ro_mch ","
        ro_milestone ","
        ro_batch format "->>>>>>>>>9.9<<<<"  ","
        ro_user1 ","
        ro_user2 ","
        ro_std_op ","
        ro_setup_men format "->>>>>>>9.99" ","
        ro_men_mch format "->>>>>>>9.99" ","
        ro_mch_op format "->>>>>>>9" ","
        ro_lbr_ovhd format "->>>>>9.999" ","
        ro_queue format "->>>>9.9<<" ","
        ro_wait format "->>>>9.9<<" ","
        ro_sub_lead format "->>>>>>>9" ","  
        ro_cyc_unit format "->>>>>>>9" "," 
        ro_cyc_rate format "->>>>>>9.999" ","""
        ro__chr01 ""","""
        ro__chr02 ""","""
        ro__chr03 ""","""
        ro__chr04 ""","""
        ro__chr05 """,".
        if ro__dte01 = ? then do:
            put ",".
        end.
        else do:
            put string(year(ro__dte01),"9999") + "-" + string(month(ro__dte01),"99") + "-" + string(day(ro__dte01),"99") format "x(10)" ",".
        end.
        if ro__dte02 = ? then do:
            put ",".
        end.
        else do:
            put string(year(ro__dte02),"9999") + "-" + string(month(ro__dte02),"99") + "-" + string(day(ro__dte02),"99") format "x(10)" ",".
        end.
      put
        ro__dec01 format "->>>>>>>>>9.9<<<" ","
        ro__dec02 format "->>>>>>>>>9.9<<<" ","
        ro__log01 ","
        ro_std_batch format "->>>>>>>>>9.9<<<" ","
        ro_rollup ","
        ro_rollup_id ","
        ro_elm_lbr ","
        ro_elm_bdn ","
        ro_elm_sub ","
        ro_start_ecn ","
        ro_end_ecn ","
        ro_po_nbr ","
        ro_po_line format "->>>>>>>9" ","
        ro_mv_nxt_op ","
        ro_wipmtl_part ","
        ro_auto_lbr ","
        ro_bom_code  ","
        ro_cost format "->>>>>>>>>>>9.9<<" ","
        ro_fsm_type ","
        ro_price format "->>>>>>>>>>>9.9<<" "," .
        if ro_mod_date = ? then do:
            put ",".
        end.
        else do:
            put string(year(ro_mod_date),"9999") + "-" + string(month(ro_mod_date),"99") + "-" + string(day(ro_mod_date),"99") format "x(10)" ",".
        end.
      put
        ro_mod_userid ","""
        ro__qadc01 ""","""
        ro__qadc02 ""","""
        ro__qadc03 ""","
        ro__qade01 format "->>>>>>>>>>9.9<" ","
        ro__qade02 format "->>>>>>>>>>9.9<" ",".
        if ro__qadt01 = ? then do:
            put ",".
        end.
        else do:
            put string(year(ro__qadt01),"9999") + "-" + string(month(ro__qadt01),"99") + "-" + string(day(ro__qadt01),"99") format "x(10)" ",".
        end.
        if ro__qadt02 = ? then do:
            put ",".
        end.
        else do:
            put string(year(ro__qadt02),"9999") + "-" + string(month(ro__qadt02),"99") + "-" + string(day(ro__qadt02),"99") format "x(10)" ",".
        end.
     put
        ro__qadl01 ","
        ro__qadl02 ","""
        ro_fsc_code """"
        .
     put skip.
end.

output close.
